//package com.ruoyi.stock2.thread.aboutDownloadData;
//
//import com.ruoyi.common.utils.spring.SpringUtils;
//import com.ruoyi.stock2.domain.DownTradedataSchedule;
//import com.ruoyi.stock2.domain.PriceCompAverage;
//import com.ruoyi.stock2.domain.STOCK;
//import com.ruoyi.stock2.domain.TRADEDATA;
//import com.ruoyi.stock2.mapper.*;
//import com.ruoyi.stock2.utils.DateUtils2;
//import com.ruoyi.stock2.utils.NameAndValue;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//
//import java.math.BigDecimal;
//import java.util.ArrayList;
//import java.util.Collections;
//import java.util.Date;
//import java.util.List;
//import java.util.concurrent.ConcurrentLinkedQueue;
//
////主要功能是往这个表里插入均线走势，用于均线走势的分类 CompPingjunThread.java 运行完成后 再执行这个
//public class PriceCompareAverage4 {
//    private static final Logger log = LoggerFactory.getLogger(PriceCompareAverage4.class);
//    String beginDateTime = "";
//    boolean working = false;
//    TRADEDATAMapper tradedataMapper;
//    PriceCompAverageMapper priceCompareAverageMapper;
//    PriceCompAverage200Mapper priceCompareAverage200Mapper;
//    DownTradedataScheduleMapper downLoadTradedataScheduleMapper;
//
//    // 单例实现
//    public static PriceCompareAverage4 getInstance() {
//        return Singtonle.instance;
//    }
//
//    private static class Singtonle {
//        private static PriceCompareAverage4 instance = new PriceCompareAverage4();
//    }
//
//    public DownTradedataScheduleMapper getDownLoadTradedataScheduleMapper() {
//        return (DownTradedataScheduleMapper) SpringUtils.getBean(DownTradedataScheduleMapper.class);
//    }
//
//    public TRADEDATAMapper getTradeDataMapper() {
//        return (TRADEDATAMapper) SpringUtils.getBean(TRADEDATAMapper.class);
//    }
//
//    public PriceCompAverageMapper getPriceCompareAverageMapper() {
//        return (PriceCompAverageMapper) SpringUtils.getBean(PriceCompAverageMapper.class);
//    }
//
//    public PriceCompAverage200Mapper getPriceCompareAverage200Mapper() {
//        return (PriceCompAverage200Mapper) SpringUtils.getBean(PriceCompAverage200Mapper.class);
//    }
//
//    public void run() {
//        working = true;
//        priceCompareAverageMapper = getPriceCompareAverageMapper();
//        priceCompareAverage200Mapper = getPriceCompareAverage200Mapper();
//        downLoadTradedataScheduleMapper = getDownLoadTradedataScheduleMapper();
//        tradedataMapper = getTradeDataMapper();
//        priceCompareAverage();
//        working = false;
//
//    }
//
//    // 测试有返回结果
//    private void priceCompareAverage() {
//        STOCKMapper stockService = (STOCKMapper) SpringUtils.getBean(STOCKMapper.class);
//        List<STOCK> stocks = stockService.selectSTOCKList(null);
//
//        DownTradedataSchedule ac = downLoadTradedataScheduleMapper.selectDownTradedataScheduleByName("priceCompareAverageSchedule");
//
//        for (STOCK stock : stocks) {
//            if (stock.getSymbol().compareTo(ac.getValue()) <= 0) {
//                continue;
//            }
//            //log.info("priceCompareAverage stock.getSymbol()="+stock.getSymbol());
//            if ("2004-01-01".equals(getBeginDateTime())) {
//                TRADEDATA tradeDataKey = new TRADEDATA(stock.getSymbol(), DateUtils2.formatStringToDate("2004-01-01", "yyyy-MM-dd"));
//                List<TRADEDATA> list = tradedataMapper.getByKeyDateTimeDesc(tradeDataKey);
//                completePriceAverageComp(list, tradeDataKey);
//            } else {
//                TRADEDATA tradeDataKey = new TRADEDATA(stock.getSymbol(), DateUtils2.formatStringToDate("2004-01-01", "yyyy-MM-dd"));
//                List<TRADEDATA> list = tradedataMapper.get200ByKeyDateTimeDesc(tradeDataKey);
//                tradeDataKey.setDatetime( DateUtils2.formatStringToDate(beginDateTime, "yyyy-MM-dd") );
//                completePriceAverageComp(list, tradeDataKey);
//            }
//
//            downLoadTradedataScheduleMapper.updateDownTradedataSchedule(
//                    new DownTradedataSchedule("priceCompareAverageSchedule", stock.getSymbol()));
//        }
//        log.warn("完成均价比!");
//    }
//
//    public boolean isWorking() {
//        return working;
//    }
//
//    public void setWorking(boolean working) {
//        this.working = working;
//    }
//
//    public String getBeginDateTime() {
//        return beginDateTime;
//    }
//
//    public void setBeginDateTime(String beginDateTime) {
//        this.beginDateTime = beginDateTime;
//    }
//
//    private void completePriceAverageComp(List<TRADEDATA> list, TRADEDATA tradeData
//    ) {
//        // 要求大于120日均线, 60日均线值在,60+才有数据
//        // MathContext mc = new MathContext(6, RoundingMode.HALF_UP);
//        List<PriceCompAverage> temp1 = new ArrayList<PriceCompAverage>(30);
//        ConcurrentLinkedQueue<PriceCompAverage> concurrentLinkedQueue = new ConcurrentLinkedQueue<PriceCompAverage>();
//
//        for (int i = 0; i < list.size() - 120; i++) {
//
//            TRADEDATA h = list.get(i);
//            TRADEDATA g = list.get(i + 1);
//            TRADEDATA f = list.get(i + 2);
//            TRADEDATA e = list.get(i + 3);
//            TRADEDATA d = list.get(i + 4);
//            TRADEDATA c = list.get(i + 5);
//            TRADEDATA b = list.get(i + 6);
//            TRADEDATA a = list.get(i + 7);
//            TRADEDATA d60 = list.get(i + 60);
//            //tradeDataKey.getDatetime() = lastDownLoadFromSinaDate
//            //if (list.get(i).getDatetime().compareTo(beginDateTime) >= 0) {
//            if (h.getDatetime().compareTo(tradeData.getDatetime()) > 0) {
//                try {
//                    if (d60 == null && d60.getZhangfu() == null) {
//                        continue;
//                    }
//                    if (d60.getZhangfu().compareTo(new BigDecimal(10.5)) > 0
//                            || d60.getZhangfu().compareTo(new BigDecimal(-10.5)) < 0) {
//                        i = i + 61;
//                        continue;
//                    }
//
//                    PriceCompAverage pca = new PriceCompAverage();
//                    pca.setSymbol(tradeData.getSymbol());
//                    pca.setStartDate(a.getDatetime());
//                    pca.setEndDate(h.getDatetime());
//
//
//                    pca.setF5e5(f.getAverageprice5().divide(e.getAverageprice5(), 6, BigDecimal.ROUND_HALF_UP));
//                    pca.setF5d5(f.getAverageprice5().divide(d.getAverageprice5(), 6, BigDecimal.ROUND_HALF_UP));
//                    pca.setF5c5(f.getAverageprice5().divide(c.getAverageprice5(), 6, BigDecimal.ROUND_HALF_UP));
//                    pca.setF5b5(f.getAverageprice5().divide(b.getAverageprice5(), 6, BigDecimal.ROUND_HALF_UP));
//                    pca.setF5a5(f.getAverageprice5().divide(a.getAverageprice5(), 6, BigDecimal.ROUND_HALF_UP));
//
//                    pca.setF10a10(f.getAverageprice10().divide(a.getAverageprice10(), 6, BigDecimal.ROUND_HALF_UP));
//                    pca.setF10b10(f.getAverageprice10().divide(b.getAverageprice10(), 6, BigDecimal.ROUND_HALF_UP));
//                    pca.setF10c10(f.getAverageprice10().divide(c.getAverageprice10(), 6, BigDecimal.ROUND_HALF_UP));
//                    pca.setF10d10(f.getAverageprice10().divide(d.getAverageprice10(), 6, BigDecimal.ROUND_HALF_UP));
//                    pca.setF10e10(f.getAverageprice10().divide(e.getAverageprice10(), 6, BigDecimal.ROUND_HALF_UP));
//
//                    pca.setF20a20(f.getAverageprice20().divide(a.getAverageprice20(), 6, BigDecimal.ROUND_HALF_UP));
//                    pca.setF20b20(f.getAverageprice20().divide(b.getAverageprice20(), 6, BigDecimal.ROUND_HALF_UP));
//                    pca.setF20c20(f.getAverageprice20().divide(c.getAverageprice20(), 6, BigDecimal.ROUND_HALF_UP));
//                    pca.setF20d20(f.getAverageprice20().divide(d.getAverageprice20(), 6, BigDecimal.ROUND_HALF_UP));
//                    pca.setF20e20(f.getAverageprice20().divide(e.getAverageprice20(), 6, BigDecimal.ROUND_HALF_UP));
//
//                    pca.setF60a60(f.getAverageprice60().divide(a.getAverageprice60(), 6, BigDecimal.ROUND_HALF_UP));
//                    pca.setF60b60(f.getAverageprice60().divide(b.getAverageprice60(), 6, BigDecimal.ROUND_HALF_UP));
//                    pca.setF60c60(f.getAverageprice60().divide(c.getAverageprice60(), 6, BigDecimal.ROUND_HALF_UP));
//                    pca.setF60d60(f.getAverageprice60().divide(d.getAverageprice60(), 6, BigDecimal.ROUND_HALF_UP));
//                    pca.setF60e60(f.getAverageprice60().divide(e.getAverageprice60(), 6, BigDecimal.ROUND_HALF_UP));
//
//
//                    pca.setA1a10(a.getCloseprice().divide(a.getAverageprice10(), 6, BigDecimal.ROUND_HALF_UP));
//                    pca.setB1b10(b.getCloseprice().divide(b.getAverageprice10(), 6, BigDecimal.ROUND_HALF_UP));
//                    pca.setC1c10(c.getCloseprice().divide(c.getAverageprice10(), 6, BigDecimal.ROUND_HALF_UP));
//                    pca.setD1d10(d.getCloseprice().divide(d.getAverageprice10(), 6, BigDecimal.ROUND_HALF_UP));
//                    pca.setE1e10(e.getCloseprice().divide(e.getAverageprice10(), 6, BigDecimal.ROUND_HALF_UP));
//                    pca.setF1f10(f.getCloseprice().divide(f.getAverageprice10(), 6, BigDecimal.ROUND_HALF_UP));
//
//                    pca.setA1a20(a.getCloseprice().divide(a.getAverageprice20(), 6, BigDecimal.ROUND_HALF_UP));
//                    pca.setB1b20(b.getCloseprice().divide(b.getAverageprice20(), 6, BigDecimal.ROUND_HALF_UP));
//                    pca.setC1c20(c.getCloseprice().divide(c.getAverageprice20(), 6, BigDecimal.ROUND_HALF_UP));
//                    pca.setD1d20(d.getCloseprice().divide(d.getAverageprice20(), 6, BigDecimal.ROUND_HALF_UP));
//                    pca.setE1e20(e.getCloseprice().divide(e.getAverageprice20(), 6, BigDecimal.ROUND_HALF_UP));
//                    pca.setF1f20(f.getCloseprice().divide(f.getAverageprice20(), 6, BigDecimal.ROUND_HALF_UP));
//
//                    pca.setA1a60(a.getCloseprice().divide(a.getAverageprice60(), 6, BigDecimal.ROUND_HALF_UP));
//                    pca.setB1b60(b.getCloseprice().divide(b.getAverageprice60(), 6, BigDecimal.ROUND_HALF_UP));
//                    pca.setC1c60(c.getCloseprice().divide(c.getAverageprice60(), 6, BigDecimal.ROUND_HALF_UP));
//                    pca.setD1d60(d.getCloseprice().divide(d.getAverageprice60(), 6, BigDecimal.ROUND_HALF_UP));
//                    pca.setE1e60(e.getCloseprice().divide(e.getAverageprice60(), 6, BigDecimal.ROUND_HALF_UP));
//                    pca.setF1f60(f.getCloseprice().divide(f.getAverageprice60(), 6, BigDecimal.ROUND_HALF_UP));
//
//                    pca.setA1a5h(a.getHighprice().divide(a.getAverageprice5(), 6, BigDecimal.ROUND_HALF_UP));
//                    pca.setB1b5h(b.getHighprice().divide(b.getAverageprice5(), 6, BigDecimal.ROUND_HALF_UP));
//                    pca.setC1c5h(c.getHighprice().divide(c.getAverageprice5(), 6, BigDecimal.ROUND_HALF_UP));
//                    pca.setD1d5h(d.getHighprice().divide(d.getAverageprice5(), 6, BigDecimal.ROUND_HALF_UP));
//                    pca.setE1e5h(e.getHighprice().divide(e.getAverageprice5(), 6, BigDecimal.ROUND_HALF_UP));
//                    pca.setF1f5h(f.getHighprice().divide(f.getAverageprice5(), 6, BigDecimal.ROUND_HALF_UP));
//                    pca.setG1g5h(g.getHighprice().divide(g.getAverageprice5(), 6, BigDecimal.ROUND_HALF_UP));
//                    pca.setH1h5h(h.getHighprice().divide(h.getAverageprice5(), 6, BigDecimal.ROUND_HALF_UP));
//
//                    pca.setA1a5l(a.getLowprice().divide(a.getAverageprice5(), 6, BigDecimal.ROUND_HALF_UP));
//                    pca.setB1b5l(b.getLowprice().divide(b.getAverageprice5(), 6, BigDecimal.ROUND_HALF_UP));
//                    pca.setC1c5l(c.getLowprice().divide(c.getAverageprice5(), 6, BigDecimal.ROUND_HALF_UP));
//                    pca.setD1d5l(d.getLowprice().divide(d.getAverageprice5(), 6, BigDecimal.ROUND_HALF_UP));
//                    pca.setE1e5l(e.getLowprice().divide(e.getAverageprice5(), 6, BigDecimal.ROUND_HALF_UP));
//                    pca.setF1f5l(f.getLowprice().divide(f.getAverageprice5(), 6, BigDecimal.ROUND_HALF_UP));
//                    pca.setG1g5l(g.getLowprice().divide(g.getAverageprice5(), 6, BigDecimal.ROUND_HALF_UP));
//                    pca.setH1h5l(h.getLowprice().divide(h.getAverageprice5(), 6, BigDecimal.ROUND_HALF_UP));
//
//                    pca.setA1a5c(a.getCloseprice().divide(a.getAverageprice5(), 6, BigDecimal.ROUND_HALF_UP));
//                    pca.setB1b5c(b.getCloseprice().divide(b.getAverageprice5(), 6, BigDecimal.ROUND_HALF_UP));
//                    pca.setC1c5c(c.getCloseprice().divide(c.getAverageprice5(), 6, BigDecimal.ROUND_HALF_UP));
//                    pca.setD1d5c(d.getCloseprice().divide(d.getAverageprice5(), 6, BigDecimal.ROUND_HALF_UP));
//                    pca.setE1e5c(e.getCloseprice().divide(e.getAverageprice5(), 6, BigDecimal.ROUND_HALF_UP));
//                    pca.setF1f5c(f.getCloseprice().divide(f.getAverageprice5(), 6, BigDecimal.ROUND_HALF_UP));
//                    pca.setG1g5c(g.getCloseprice().divide(g.getAverageprice5(), 6, BigDecimal.ROUND_HALF_UP));
//                    pca.setH1h5c(h.getCloseprice().divide(h.getAverageprice5(), 6, BigDecimal.ROUND_HALF_UP));
//
//                    pca.setA5a10(a.getAverageprice5().divide(a.getAverageprice10(), 6, BigDecimal.ROUND_HALF_UP));
//                    pca.setB5b10(b.getAverageprice5().divide(b.getAverageprice10(), 6, BigDecimal.ROUND_HALF_UP));
//                    pca.setC5c10(c.getAverageprice5().divide(c.getAverageprice10(), 6, BigDecimal.ROUND_HALF_UP));
//                    pca.setD5d10(d.getAverageprice5().divide(d.getAverageprice10(), 6, BigDecimal.ROUND_HALF_UP));
//                    pca.setE5e10(e.getAverageprice5().divide(e.getAverageprice10(), 6, BigDecimal.ROUND_HALF_UP));
//                    pca.setF5f10(f.getAverageprice5().divide(f.getAverageprice10(), 6, BigDecimal.ROUND_HALF_UP));
//                    pca.setG5g10(g.getAverageprice5().divide(g.getAverageprice10(), 6, BigDecimal.ROUND_HALF_UP));
//                    pca.setH5h10(h.getAverageprice5().divide(h.getAverageprice10(), 6, BigDecimal.ROUND_HALF_UP));
//
//                    pca.setA10a20(a.getAverageprice10().divide(a.getAverageprice20(), 6, BigDecimal.ROUND_HALF_UP));
//                    pca.setB10b20(b.getAverageprice10().divide(b.getAverageprice20(), 6, BigDecimal.ROUND_HALF_UP));
//                    pca.setC10c20(c.getAverageprice10().divide(c.getAverageprice20(), 6, BigDecimal.ROUND_HALF_UP));
//                    pca.setD10d20(d.getAverageprice10().divide(d.getAverageprice20(), 6, BigDecimal.ROUND_HALF_UP));
//                    pca.setE10e20(e.getAverageprice10().divide(e.getAverageprice20(), 6, BigDecimal.ROUND_HALF_UP));
//                    pca.setF10f20(f.getAverageprice10().divide(f.getAverageprice20(), 6, BigDecimal.ROUND_HALF_UP));
//                    pca.setG10g20(g.getAverageprice10().divide(g.getAverageprice20(), 6, BigDecimal.ROUND_HALF_UP));
//                    pca.setH10h20(h.getAverageprice10().divide(h.getAverageprice20(), 6, BigDecimal.ROUND_HALF_UP));
//
//                    pca.setA20a60(a.getAverageprice20().divide(a.getAverageprice60(), 6, BigDecimal.ROUND_HALF_UP));
//                    pca.setB20b60(b.getAverageprice20().divide(b.getAverageprice60(), 6, BigDecimal.ROUND_HALF_UP));
//                    pca.setC20c60(c.getAverageprice20().divide(c.getAverageprice60(), 6, BigDecimal.ROUND_HALF_UP));
//                    pca.setD20d60(d.getAverageprice20().divide(d.getAverageprice60(), 6, BigDecimal.ROUND_HALF_UP));
//                    pca.setE20e60(e.getAverageprice20().divide(e.getAverageprice60(), 6, BigDecimal.ROUND_HALF_UP));
//                    pca.setF20f60(f.getAverageprice20().divide(f.getAverageprice60(), 6, BigDecimal.ROUND_HALF_UP));
//                    pca.setG20g60(g.getAverageprice20().divide(g.getAverageprice60(), 6, BigDecimal.ROUND_HALF_UP));
//                    pca.setH20h60(h.getAverageprice20().divide(h.getAverageprice60(), 6, BigDecimal.ROUND_HALF_UP));
//
//                    pca.setD1d10vol(d.getVolume().divide(d.getVolume10(), 6, BigDecimal.ROUND_HALF_UP));
//                    pca.setE1e10vol(e.getVolume().divide(e.getVolume10(), 6, BigDecimal.ROUND_HALF_UP));
//                    pca.setF1f10vol(f.getVolume().divide(f.getVolume10(), 6, BigDecimal.ROUND_HALF_UP));
//                    pca.setD1d5vol(d.getVolume().divide(d.getVolume5(), 6, BigDecimal.ROUND_HALF_UP));
//                    pca.setE1e5vol(e.getVolume().divide(e.getVolume5(), 6, BigDecimal.ROUND_HALF_UP));
//                    pca.setF1f5vol(f.getVolume().divide(f.getVolume5(), 6, BigDecimal.ROUND_HALF_UP));
//
//                    pca.setAcompare(bijiao(a));
//                    pca.setBcompare(bijiao(b));
//                    pca.setCcompare(bijiao(c));
//                    pca.setDcompare(bijiao(d));
//                    pca.setEcompare(bijiao(e));
//                    pca.setFcompare(bijiao(f));
//                    pca.setGcompare(bijiao(g));
//                    pca.setHcompare(bijiao(h));
//
//                    pca.setA1zhangfu(a.getZhangfu());
//                    pca.setB1zhangfu(b.getZhangfu());
//                    pca.setC1zhangfu(c.getZhangfu());
//                    pca.setD1zhangfu(d.getZhangfu());
//                    pca.setE1zhangfu(e.getZhangfu());
//                    pca.setF1zhangfu(f.getZhangfu());
//                    pca.setG1zhangfu(g.getZhangfu());
//                    pca.setH1zhangfu(h.getZhangfu());
//
//                    pca.setB1date(b.getDatetime());
//                    pca.setC1date(c.getDatetime());
//                    pca.setD1date(d.getDatetime());
//                    pca.setE1date(e.getDatetime());
//                    pca.setF1date(f.getDatetime());
//                    pca.setG1date(g.getDatetime());
//
//                    pca.setAopen(a.getDateopenprice());
//                    pca.setAclose(a.getCloseprice());
//                    pca.setAhigh(a.getHighprice());
//                    pca.setAlow(a.getLowprice());
//                    pca.setA5(a.getAverageprice5());
//                    pca.setA10(a.getAverageprice10());
//                    pca.setA20(a.getAverageprice20());
//                    pca.setA60(a.getAverageprice60());
//
//                    pca.setBopen(b.getDateopenprice());
//                    pca.setBclose(b.getCloseprice());
//                    pca.setBhigh(b.getHighprice());
//                    pca.setBlow(b.getLowprice());
//                    pca.setB5(b.getAverageprice5());
//                    pca.setB10(b.getAverageprice10());
//                    pca.setB20(b.getAverageprice20());
//                    pca.setB60(b.getAverageprice60());
//
//                    pca.setCopen(c.getDateopenprice());
//                    pca.setCclose(c.getCloseprice());
//                    pca.setChigh(c.getHighprice());
//                    pca.setClow(c.getLowprice());
//                    pca.setC5(c.getAverageprice5());
//                    pca.setC10(c.getAverageprice10());
//                    pca.setC20(c.getAverageprice20());
//                    pca.setC60(c.getAverageprice60());
//
//                    pca.setDopen(d.getDateopenprice());
//                    pca.setDclose(d.getCloseprice());
//                    pca.setDhigh(d.getHighprice());
//                    pca.setDlow(d.getLowprice());
//                    pca.setD5(d.getAverageprice5());
//                    pca.setD10(d.getAverageprice10());
//                    pca.setD20(d.getAverageprice20());
//                    pca.setD60(d.getAverageprice60());
//
//                    pca.setEopen(e.getDateopenprice());
//                    pca.setEclose(e.getCloseprice());
//                    pca.setEhigh(e.getHighprice());
//                    pca.setElow(e.getLowprice());
//                    pca.setE5(e.getAverageprice5());
//                    pca.setE10(e.getAverageprice10());
//                    pca.setE20(e.getAverageprice20());
//                    pca.setE60(e.getAverageprice60());
//
//                    pca.setFopen(f.getDateopenprice());
//                    pca.setFclose(f.getCloseprice());
//                    pca.setFhigh(f.getHighprice());
//                    pca.setFlow(f.getLowprice());
//                    pca.setF5(f.getAverageprice5());
//                    pca.setF10(f.getAverageprice10());
//                    pca.setF20(f.getAverageprice20());
//                    pca.setF60(f.getAverageprice60());
//
//                    pca.setCreateDate(new Date());
//
//                    PriceCompAverage key = new PriceCompAverage(tradeData.getSymbol(), a.getDatetime(), h.getDatetime());
//                    List<PriceCompAverage> objs = priceCompareAverageMapper.selectPriceCompAverageList(key);
//                    if (objs == null || objs.size() == 0) {
//                        concurrentLinkedQueue.offer(pca);
//                    } else {
//                        priceCompareAverageMapper.updatePriceCompAverage(pca);
//                    }
//                }catch (java.lang.NullPointerException e1){
//                    System.out.println(tradeData.getSymbol()+"数据为空");
//                }
//            } else {
//                break;
//            }
//
//        }
//        if (concurrentLinkedQueue.size() > 0) {
//
//            for (PriceCompAverage obj : concurrentLinkedQueue) {
//                temp1.add(obj);
//                if (temp1.size() == 30) {
//                    priceCompareAverageMapper.inserts(temp1);
//                    temp1.clear();
//                }
//            }
//
//            if (temp1.size() > 0) {
//                priceCompareAverageMapper.inserts(temp1);
//                temp1.clear();
//            }
//        }
//
//
//    }
//
//    private String bijiao(TRADEDATA td) {
//
//        BigDecimal a60 = td.getAverageprice60().setScale(2, BigDecimal.ROUND_HALF_UP);
//        BigDecimal a20 = td.getAverageprice20().setScale(2, BigDecimal.ROUND_HALF_UP);
//        BigDecimal a10 = td.getAverageprice10().setScale(2, BigDecimal.ROUND_HALF_UP);
//        BigDecimal a5 = td.getAverageprice5().setScale(2, BigDecimal.ROUND_HALF_UP);
//
//        List<NameAndValue> list = new ArrayList<NameAndValue>();
//        list.add(new NameAndValue("5", a5));
//        list.add(new NameAndValue("60", a60));
//        list.add(new NameAndValue("10", a10));
//        list.add(new NameAndValue("20", a20));
//
//        Collections.sort(list);
//        StringBuffer sb = new StringBuffer();
//        for (int i = 0; i < list.size() - 1; i++) {
//            if (list.get(i).getValue().compareTo(list.get(i + 1).getValue()) < 0) {
//                sb.append(list.get(i).getName()).append("<");
//            }
//            if (list.get(i).getValue().compareTo(list.get(i + 1).getValue()) == 0) {
//                sb.append(list.get(i).getName()).append("=");
//            }
//            if (list.get(i).getValue().compareTo(list.get(i + 1).getValue()) > 0) {
//                sb.append(list.get(i).getName()).append(">");
//            }
//        }
//        sb.append(list.get(list.size() - 1).getName());
//        return sb.toString()
//                .replace("20=10", "10=20")
//                .replace("60=10", "10=60")
//                .replace("10=5", "5=10")
//                .replace("20=5", "5=20")
//                .replace("60=5", "5=60")
//                .replace("60=20", "20=60");
//    }
//}
